﻿@each $breakpoint in map-keys($grid-breakpoints) {
    @include media-breakpoint-up($breakpoint) {
        $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

        @each $prop, $abbrev in (margin: fui-Margin, padding: fui-Padding) {
            @each $size, $length in $spacers {
                .#{$abbrev}#{$infix}-#{$size} {
                    #{$prop}: $length !important;
                }

                .#{$abbrev}-top#{$infix}-#{$size},
                .#{$abbrev}-y#{$infix}-#{$size} {
                    #{$prop}-top: $length !important;
                }

                .#{$abbrev}-end#{$infix}-#{$size},
                .#{$abbrev}-x#{$infix}-#{$size} {
                    #{$prop}-right: $length !important;
                }

                .#{$abbrev}-bottom#{$infix}-#{$size},
                .#{$abbrev}-y#{$infix}-#{$size} {
                    #{$prop}-bottom: $length !important;
                }

                .#{$abbrev}-start#{$infix}-#{$size},
                .#{$abbrev}-x#{$infix}-#{$size} {
                    #{$prop}-left: $length !important;
                }
            }
        }
        // Negative margins (e.g., where `.mb-n1` is negative version of `.mb-1`)
        @each $size, $length in $spacers {
            @if $size != 0 {
                .fui-Margin#{$infix}-n#{$size} {
                    margin: -$length !important;
                }

                .fui-Margin-top#{$infix}-n#{$size},
                .fui-Margin-y#{$infix}-n#{$size} {
                    margin-top: -$length !important;
                }

                .fui-Margin-end#{$infix}-n#{$size},
                .fui-Margin-x#{$infix}-n#{$size} {
                    margin-right: -$length !important;
                }

                .fui-Margin-bottom#{$infix}-n#{$size},
                .fui-Margin-y#{$infix}-n#{$size} {
                    margin-bottom: -$length !important;
                }

                .fui-Margin-start#{$infix}-n#{$size},
                .fui-Margin-x#{$infix}-n#{$size} {
                    margin-left: -$length !important;
                }
            }
        }
        // Some special margin utils
        .fui-Margin#{$infix}-auto {
            margin: auto !important;
        }

        .fui-Margin-top#{$infix}-auto,
        .fui-Margin-y#{$infix}-auto {
            margin-top: auto !important;
        }

        .fui-Margin-end#{$infix}-auto,
        .fui-Margin-x#{$infix}-auto {
            margin-right: auto !important;
        }

        .fui-Margin-bottom#{$infix}-auto,
        .fui-Margin-y#{$infix}-auto {
            margin-bottom: auto !important;
        }

        .fui-Margin-start#{$infix}-auto,
        .fui-Margin-x#{$infix}-auto {
            margin-left: auto !important;
        }
    }
}

@each $size, $length in $spacers {
    .fui-Gap-#{$size} {
        gap: $length !important;
    }

    .fui-Gap-y-#{$size} {
        row-gap: $length !important;
    }

    .fui-Gap-x-#{$size} {
        column-gap: $length !important;
    }
}
